<template>
  <ContentWrap>
<!-- 搜索工作栏 -->
    <el-form
        class="-mb-15px form-card search-bar"
        :model="queryParams"
        ref="queryFormRef"
        :inline="true"
        label-width="100px"
      >
          <el-form-item label="订单编号" prop="orderCode">
          <el-input
            v-model="queryParams.orderCode"
            placeholder="请输入订单编号"
            clearable
            class="!w-240px"
            @keyup.enter="handleQuery"
          />
        </el-form-item>
          <el-form-item label="内码" prop="internalCode">
          <el-input
            v-model="queryParams.internalCode"
            placeholder="请输入内码"
            clearable
            class="!w-240px"
            @keyup.enter="handleQuery"
          />
        </el-form-item>
          <el-form-item label="工位" prop="scaleId">
          <el-input
            v-model="queryParams.scaleId"
            placeholder="请输入工位"
            clearable
            class="!w-240px"
            @keyup.enter="handleQuery"
          />
        </el-form-item>
          <el-form-item label="规格型号" prop="type">
          <el-input
            v-model="queryParams.type"
            placeholder="请输入规格型号"
            clearable
            class="!w-240px"
            @keyup.enter="handleQuery"
          />
        </el-form-item>
          <el-form-item label="电子称" prop="scaleName">
          <el-input
            v-model="queryParams.scaleName"
            placeholder="请输入电子称"
            clearable
            class="!w-240px"
            @keyup.enter="handleQuery"
          />
        </el-form-item>
      <el-form-item label="订单规格" prop="flex">
        <el-input
          v-model="queryParams.flex"
          placeholder="请输入订单规格"
          clearable
          class="!w-240px"
          @keyup.enter="handleQuery"
        />
      </el-form-item>
      <el-form-item label="长度" prop="len">
        <el-input-number
          v-model="queryParams.len"
          placeholder="请输入长度"
          clearable
          class="!w-240px"
          @keyup.enter="handleQuery"
        />
      </el-form-item>
          <el-form-item label="称重日期" prop="dateReq">
          <el-date-picker
            v-model="queryParams.dateReq"
            value-format="YYYY-MM-DD"
            type="daterange"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            class="!w-240px"
          />
        </el-form-item>
          <el-form-item>
          <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
          <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
        </el-form-item>
      </el-form>
      
    </ContentWrap>
  <!-- 列表 -->
  <ContentWrap>
      <el-table v-loading="loading" :data="list">
        <el-table-column type="index" label="序号" align="center" width="55" />
        <el-table-column label="订单编号" align="center" prop="orderCode" />
        <el-table-column label="规格型号" align="center" prop="type" />
        <el-table-column label="内码" align="center" prop="internalCode" />
        <el-table-column label="电子称" align="center" prop="scaleName" />
<!--        <el-table-column label="内码" align="center" prop="internalCode" /> -->
        <el-table-column label="重量" align="center" prop="weight" />
        <el-table-column label="订单规格" align="center" prop="flex" />
        <el-table-column label="长度" align="center" prop="len" />
        <el-table-column label="操作时间" align="center" prop="operatingTime" />
      </el-table>
      <!-- 分页 -->
      <Pagination
        :total="total"
        v-model:page="queryParams.pageNo"
        v-model:limit="queryParams.pageSize"
        @pagination="getList"
      />
    </ContentWrap>
    
  </template>
  
  <style scoped>

  </style>

  <script lang="ts" setup>
  import * as weightReportApi from '@/api/hcxly/weightReport/Index'
  
  defineOptions({ name: 'weightReport' })
  
  const message = useMessage() // 消息弹窗
  const { t } = useI18n() // 国际化
  
  const loading = ref(true) // 列表的加载中
  const total = ref(0) // 列表的总页数
  const list = ref([]) // 列表的数据

  const queryParams = reactive({
    pageNo: 1,
    pageSize: 10,
    orderCode: '',
    internalCode: '',
    scaleId: null,
    type: '',
    scaleName: '',
    dateReq: [],
    flex: '',
    len: null
  })
  const queryFormRef = ref() // 搜索的表单
  const exportLoading = ref(false) // 导出的加载中
  
  /** 查询列表 */
  const getList = async () => {
    loading.value = true
    try {
      const data = await weightReportApi.getweightReport(queryParams)
      console.log(data)
      list.value = data.list
      total.value = data.total
    } finally {
      loading.value = false
    }
  }
  
  /** 搜索按钮操作 */
  const handleQuery = () => {
    queryParams.pageNo = 1
    getList()
  }
  
  /** 重置按钮操作 */
  const resetQuery = () => {
    queryFormRef.value.resetFields()
    handleQuery()
  }

  /** 初始化 **/
  onMounted(() => {
    getList()
  })
  
  </script>
